<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>用户</title> 
    <link href="${root}/js/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <link href="${root}/js/lib/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
    <link href="${root}/js/lib/css/common.css" rel="stylesheet" type="text/css" />  
    <script src="${root}/js/lib/jquery/jquery-1.5.2.min.js" type="text/javascript"></script>
    <script src="${root}/js/lib/ligerUI/js/ligerui.min.js" type="text/javascript"></script>   
    <script src="${root}/js/lib/json2.js" type="text/javascript"></script>
    <script src="${root}/js/common/common.js" type="text/javascript"></script>   
    <script src="${root}/js/common/LG.js" type="text/javascript"></script>   
    <script src="${root}/js/common/ligerui.expand.js" type="text/javascript"></script> 
</head> 
<body style="padding:10px;height:100%; text-align:center;">
   <ipnut type="hidden" id="MenuNo" value="MemberManageUser" />  
  <div id="mainsearch" style=" width:98%">
    <div class="searchtitle"> 
        <span>搜索</span><img src="../lib/icons/32X32/searchtool.gif" />
        <div class="togglebtn"></div> 
    </div>
    <div class="navline" style="margin-bottom:4px; margin-top:4px;"></div>
    <div class="searchbox">
        <form id="formsearch" class="l-form"></form> 
    </div>
  </div> 
  <div id="maingrid"></div> 
  <script type="text/javascript">
	  var userColumns=[
		{ display: '登录名称', name: 'login_name', align: 'left', width: 120 }, 
		{ display: '显示名称', name: 'nickname', align: 'left', width: 120 },
		{ display: '部门', name: 'department_id', align: 'left', width: 120 },
		{ display: '用户状态', name: 'status', align: 'left', width: 120 },
		{ display: '描述', name: 'remark', align: 'left', width: '100%' }
	]; 
		var toolbarItems=[
		         		{id:'add',text:'新增',click:toolbarBtnItemClick},
		         		{line:true},
		         		{id:'modify',text:'修改',click:toolbarBtnItemClick},
		         		{line:true},
		         		{id:'delete',text:'删除',click:toolbarBtnItemClick},
		         		{line:true},
		         		{id:'view',text:'查看',click:toolbarBtnItemClick}
		         		];
      //相对路径
      var rootPath = "${root}/";
      //列表结构
      var grid = $("#maingrid").ligerGrid({
          columns: userColumns, dataAction: 'server', pageSize: 20, toolbar: {},
          url: rootPath + 'app/userList', sortName: 'login_name', 
          width: '98%', height: '100%',heightDiff:-10, checkbox: false
      });

        //双击事件
      //LG.setGridDoubleClick(grid, 'modify');

      /*//搜索表单应用ligerui样式
      $("#formsearch").ligerForm({
		   fields:[],
		   appendID:false,
		   toJSON: JSON2.stringify 
	  });*/

      //增加搜索按钮,并创建事件
      //LG.appendSearchButtons("#formsearch", grid);

      //加载toolbar
      //LG.loadToolbar(grid, toolbarBtnItemClick);
      grid.toolbarManager.set('items', toolbarItems);

      //工具条事件
      function toolbarBtnItemClick(item) {
          switch (item.id) {
              case "add":
                  top.f_addTab(null, '增加用户信息', '${root}/jsp/systemManager/userManager/UserDetail.jsp?IsView=0&ID=0');
                  break;
              case "view":
                  var selected = grid.getSelected();
                  if (!selected) { LG.tip('请选择行!'); return; }
                  top.f_addTab(null, '查看用户信息', '${root}/jsp/systemManager/userManager/UserDetail.jsp?IsView=1&ID=' + selected.user_id);
                  break;
              case "modify":
                  var selected = grid.getSelected();
                  if (!selected) { LG.tip('请选择行!'); return; }
                  top.f_addTab(null, '修改用户信息', '${root}/jsp/systemManager/userManager/UserDetail.jsp?IsView=0&ID=' + selected.user_id);
                  break;
              case "delete":
                  jQuery.ligerDialog.confirm('确定删除吗?', function (confirm) {
                      if (confirm)
                          f_delete();
                  });
                  break;
          }
      }
      function f_reload() {
          grid.loadData();
      }
      function f_delete() {
          var selected = grid.getSelected();
          if (selected) {
              LG.ajax({
                  type: '/removeUser',
                  loading: '正在删除中...',
                  data: { ID: selected.user_id },
                  success: function () {
                      LG.showSuccess('删除成功');
                      f_reload();
                  },
                  error: function (message) {
                      LG.showError(message);
                  }
              });
          }
          else {
              LG.tip('请选择行!');
          }
      }
  </script>
</body>
</html>
